<?php

/**
 * \class theme_roller
 * \brief This class includes the css themes according to the selection.
 * \author  Salman Noor
 */
class theme_roller {

    /**
     * \brief The string that Initialises the jQuery path.
     */
    private $jQuery_library_path = "<script type=\"text/javascript\" src=\"client/jquery-1.5.1.min.js\"></script>";
    /**
     * \brief The string that Initialises the jQuery UI library path.
     */
    private $jQuery_UI_library_path = "<script type=\"text/javascript\" src=\"client/jquery-ui-1.8.12.custom.min.js\"></script>";
    /**
     * \brief The string that set the CSS type.
     */
    private $CSS_type = 'ui-lightness';
    /**
     * \brief The string reads the xml theme roller object.
     */
    private $xml_t_roller;

      public function __construct($selectTheme)
    {
          if (isset ($selectTheme))
          {
             $this->CSS_type = $selectTheme;
              $this->setTheme();
              echo $this->jQuery_UI_library_path;
          }
          else
          {
               $this->xml_t_roller = simplexml_load_file("ThemeRoller.xml")
       or die("Error: Cannot create object");
               $this->getSelectedTheme();
              $this->setTheme();
          $this->setUpJqueryLibraries();        
          }

    }

    /**
     * \brief This function returns the selected theme.
     */
    private function getSelectedTheme() {
        foreach ($this->xml_t_roller->children() as $themes) {
            foreach ($themes->children() as $theme => $data) {
                $this->CSS_type = $data->name;
            }
        }
    }

    /**
     * \brief This function sets up the jQueru library path and the jQuery UI
     * library path.
     */
    private function setUpJqueryLibraries() {
        echo $this->jQuery_library_path;
        echo $this->jQuery_UI_library_path;
    }

    /**
     * \brief This function sets the slected theme.
     */
    private function setTheme() {
        echo $CSS_path = "<link type=\"text/css\" href=\"css/$this->CSS_type/jquery-ui-1.8.12.custom.css\" rel=\"stylesheet\" />";
    }

    /**
     * \brief This function creates the theme viewer.
     */
    public function createThemeViewer() {
        return $themeViewer = "<div class='demo'>

Date: <div id='datepicker'></div>

</div>";
    }

}
?>
